<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let m1 = new Map()
        m1.set('001', { id: '001', name: '董卓', age: 18 })
        m1.set('002', { id: '002', name: '杨幂', age: 28 })
        m1.set('003', { id: '003', name: '加拿大克里斯', age: 11 })

        // console.dir( m1.keys());
        let iterator = m1.keys()  //迭代器,迭代器一开始指向第一个元素的前面

        console.log(iterator.next());        //是迭代器才能使用next()
        console.log(iterator.next());
        console.log(iterator.next());
        console.log('==================================');
        
        let iterator2 = m1.values()

        console.log(iterator2.next());
        console.log(iterator2.next());
        console.log(iterator2.next());
        console.log('==================================');

        let iterator3 =m1.values()
        let v = iterator3.next()

        while(v.done==false){              //迭代器里元素.done:false 就是说明还没有到头,next还有元素,
            console.log(v)                 //如果done:true 说明已经循环到底,后面没有元素了
            v=iterator3.next()
        }   //使用while,完成next()
        
        console.log('==================================');
        let iterator4=m1.values()
        for(let v of iterator4){
            console.log(v);
        }
    </script>
</body>

</html>